package mapper.SchoolRecruitManagement;

import entity.Recruitment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.LinkedHashMap;
import java.util.List;

@Repository
public interface SchoolRecruitMapper {

    @Select("select Recruitment.enterpriseId,Enterprise.name as enterpriseName ,Recruitment.name1 as recruitmentName ,Recruitment.beginTime,Recruitment.endTime,Recruitment.describe1 as RecruitmentDescribe,Recruitment.address,Recruitment.school,Recruitment.date from Recruitment,Enterprise " +
            "where Recruitment.enterpriseId=Enterprise.enterpriseId and " +
                   "Recruitment.date>=(select now() as Systemtime) and " +
                    "Recruitment.school = (select UserInfForStu.school from User,UserInfForStu where UserInfForStu.phoneNumber=#{userId} LIMIT 1)")
    public List<LinkedHashMap<String,Object>> select_recruitment(@Param("userId") String userId);

    @Select("select Recruitment.enterpriseId,Enterprise.name as enterpriseName ,Recruitment.name1 as recruitmentName ,Recruitment.beginTime,Recruitment.endTime,Recruitment.describe1 as RecruitmentDescribe,Recruitment.address,Recruitment.school,Recruitment.date from Recruitment,Enterprise where Recruitment.enterpriseId=Enterprise.enterpriseId AND Recruitment.enterpriseId = (select enterpriseId from UserInfForEn where UserInfForEn.phoneNumber=#{userId} LIMIT 1)")
    public List<LinkedHashMap<String,Object>> select_myrecruitment(@Param("userId") String userId);

    @Insert("insert into Recruitment(enterpriseId,name1,describe1,beginTime,address,school,endTime,date) values(#{enterpriseId},#{name},#{describe},#{beginTime},#{address},#{school},#{endTime},#{date})")
    public int addRecruitment(Recruitment recruitment);

}
